<template>
    <div>
        <div ref="canvas" class="html-canvas">
            <div class="test" @click="share">测试</div>
            <div>
                <a class="down" href="">下载</a>
            </div>
            <div>
                <a class="down2" href="">下载2</a>
            </div>
        </div>
        <img :src="imgUrl" >
    </div>
</template>

<script>
    import html2canvas from 'html2canvas'
    export default {
        name : "index",
        data(){
            return{
                imgUrl:''
            }
        },
        methods:{
            share(){
                let self = this
                html2canvas(this.$refs.canvas, { scale: 2, logging: false, useCORS: true }).then(function (canvas) {
                    let dataUrl = canvas.toDataURL("image/png")
                    self.imgUrl = dataUrl
                })
            }
        }
    }
</script>

<style scoped>

</style>